{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <!--<div class="layui-form layui-form-item">-->

                    <!--<div class="layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text"  name="start" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="开始时间"/>-->
                    <!--</div>-->

                    <!--<div class="layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text"  name="end" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="结束时间"/>-->
                    <!--</div>-->

                    <!--<div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="标题"/>-->
                    <!--</div>-->
                    <!--<div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">-->
                    <!--<select name="province" lay-search="" id="province"  lay-filter="province">-->
                    <!--<option value="">全部</option>-->
                    <!--<option value="1" >上架中</option>-->
                    <!--<option value="2" >已下架</option>-->
                    <!--</select>-->
                    <!--</div>-->
                    <!--<div class="layui-input-inline" style="margin-top: 5px">-->
                    <!--<button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>-->
                    <!--<button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>-->
                    <!--</div>-->
                    <!--</div>-->
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('add')}');">
                            <i class="fa fa-plus"></i> 添加
                        </button>
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('unbookAdd')}');" style="margin-left: 5px">-->
                        <!--<i class="fa fa-plus"></i> 添加非图书-->
                        <!--</button>-->

                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--&lt;!&ndash;<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>&ndash;&gt;-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-check-circle"></i> 批量上架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-ban"></i> 批量下架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <!--<div class="col-sm-12">-->
                <!--<div class="input-group" >-->
                <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                <!--</button>-->
                <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                <!--<li><a href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-check-circle"></i> 批量导入 </a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-ban"></i> 批量上架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-trash-o"></i> 批量下架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-trash-o"></i> 批量删除</a></li>-->
                <!--&lt;!&ndash;<li><a  href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-external-link"></i> 批量导入</a></li>&ndash;&gt;-->
                <!--</ul>-->
                <!--</div>-->
                <!--</div>-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.video_modular_img}}" class="table-img layui-cricle" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <script type="text/html" id="is_xbxg">
                    {{# if(d.is_xbxg == 1){ }}
                    是
                    {{# } }}
                    {{# if(d.is_xbxg == 2){ }}
                    否
                    {{# } }}
                    </script>
                    <script type="text/html" id="is_cd">
                        {{# if(d.is_cd == 1){ }}
                        是
                        {{# } }}
                        {{# if(d.is_cd == 2){ }}
                        否
                        {{# } }}
                    </script>
                    <script type="text/html" id="is_yybz">
                        {{# if(d.is_yybz == 1){ }}
                        是
                        {{# } }}
                        {{# if(d.is_yybz == 2){ }}
                        否
                        {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.href('{:url('update')}?id={{d.video_modular_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        {{# if(d.is_xbxg == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('xbxg1')}','确定取消放在新编戏歌吗?')" class="btn btn-primary btn-xs m-r-xs" title="新编戏歌">取消新编戏歌</a>
                        {{# } }}
                        {{# if(d.is_xbxg ==2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('xbxg')}','确定放在新编戏歌吗?')" class="btn btn-primary btn-xs m-r-xs" title="新编戏歌">确定新编戏歌</a>
                        {{# } }}

                        {{# if(d.is_cd == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('cd1')}','确定取消放在唱段吗?')" class="btn btn-primary btn-xs m-r-xs" title="唱段">取消唱段</a>
                        {{# } }}
                        {{# if(d.is_cd ==2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('cd')}','确定放在唱段吗?')" class="btn btn-primary btn-xs m-r-xs" title="唱段">确定唱段</a>
                        {{# } }}

                        {{# if(d.is_yybz == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('yybz1')}','确定取消放在放在音乐伴奏吗?')" class="btn btn-primary btn-xs m-r-xs" title="音乐伴奏">取消音乐伴奏</a>
                        {{# } }}
                        {{# if(d.is_yybz ==2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('yybz')}','确定放在音乐伴奏吗?')" class="btn btn-primary btn-xs m-r-xs" title="音乐伴奏">确定音乐伴奏</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.video_modular_id}}','{:url('del')}','确定删除吗?')" class="btn btn-primary btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("modular/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type:'numbers', width: 80, title: '序号'}
//                , {field: 'banner_id', width: 80, title: 'ID', align: 'center'}
                {field: 'video_modular_id', width: 50, title: 'ID', align: 'center'}
                , {field: 'video_modular_name', width: 150, title: '名称', align: 'center'}
                , {field: 'video_modular_img', width: 150, title: '缩略图', align: 'center',templet:"#imgTpl"}
                , {field: 'is_xbxg', width: 150, title: '放在新编戏歌', align: 'center',templet:"#is_xbxg"}
                , {field: 'is_cd', width: 150, title: '放在唱段', align: 'center',templet:"#is_cd"}
                , {field: 'is_yybz', width: 150, title: '放在音乐伴奏', align: 'center',templet:"#is_yybz"}
                , {fixed: 'right', width:450, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.layui-cricle').viewer();//图片查看器
            }
        });
        //监听单元格编辑
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            var patrn = /^[0-9]*$/;
            if(!patrn.test(value)){
                layer.msg('排序值只能为数字',{icon:2,time:1500,shade: 0.1},function(){
                    //重载当前页表格
                    $(".layui-laypage-btn").click();
                });
                return false;
            }
            wk.changeSort(data.banner_id,"{:url('sort')}",field,value);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>